package main

import (
	"fmt"
	"strconv"
)

// 结构体类型
// 相当于定义一个类
type People struct {
	name string
	age  int
}

// 给结构体加方法
// 相当于给类加方法
func (p People) String() string {
	return fmt.Sprintf("people : %s, %s", p.name, strconv.Itoa(p.age))
}

// 组合
// 属性屏蔽。同名属性会屏蔽
type Employee struct {
	People
	company string
	name    string
}

// 同名方法也会屏蔽
func (e Employee) String() string {
	return fmt.Sprintf("employee : %s,%s, %s", e.company, e.name, e.People)
}

func main() {
	p := People{
		name: "yunsheng",
		age:  30,
	}
	fmt.Printf("p is : %s\n", p)

	e := Employee{
		People:  p,
		company: "google",
		name:    "zhangsan",
	}
	fmt.Printf("e is : %s\n", e)
}
